#include "Functions/Draw.h"
#include "RooArgusBG.h"
#include "RooPlot.h"
#include "RooRealVar.h"
#include "TCanvas.h"
#include "TLegend.h"
#include "TVirtualPad.h"
#include <vector>
using namespace BOSS_Afterburner::Draw;
using namespace RooFit;
using namespace std;

namespace values
{
  vector<double> c{-1, -.5, -.1, 1, 2, 4, 8};
  vector<double> p{-10, -1, -.1, 1, 5, 10};
} // namespace values

void DrawArgusShapes()
{
  const char* unit = "GeV/#it{c}^{2}";
  RooRealVar  x("m", "m", 0., 300., unit);
  RooRealVar  m0("m_{0}", "m_{0}", 900, unit);
  RooRealVar  c("c", "c", 10);
  RooRealVar  p("p", "p", 10);
  RooArgusBG  argus("argus", "argus", x, m0, c, p);

  auto m0_frame =
    x.frame(Title("Argus for different values of #it{m}_{0}, #it{c} = 10, #it{p} = 10"));
  TCanvas canvas;

  /// -# Different values for m0.
  TLegend legend_m0(.5, .6, .92, .92, "Argus shapes:");
  m0.setVal(300);
  c.setVal(10);
  p.setVal(10);
  Color_t colour;
  colour = 41; // https://root.cern.ch/doc/master/classTColor.html
  for(double val = 200.; val < 800.; val += 100.)
  {
    m0.setVal(val);
    const char* name = Form("Argus_m0=%g", val);
    argus.plotOn(m0_frame, LineColor(colour), Name(name));
    legend_m0.AddEntry(m0_frame->findObject(name), Form("m_{0} = %g %s", val, unit));
    ++colour;
  }
  m0_frame->Draw();
  legend_m0.Draw();
  SaveCanvas("Argus_m0");

  /// -# Different values for p.
  auto p_frame =
    x.frame(Title("Argus for different values of #it{p}, #it{c} = 10, #it{m}_{0} = 300"));
  m0.setVal(300);
  c.setVal(10);
  p.setVal(10);
  gPad->Clear();
  TLegend legend_p(.5, .6, .92, .92, "Argus shapes:");
  colour = 41;
  for(auto pval : values::p)
  {
    p.setVal(pval);
    const char* name = Form("Argus_p=%d", pval);
    argus.plotOn(p_frame, LineColor(colour), Name(name));
    legend_p.AddEntry(p_frame->findObject(name), Form("#it{p} = %g", pval));
    ++colour;
  }
  p_frame->Draw();
  legend_p.Draw();
  SaveCanvas("Argus_p");

  /// -# Different values for c.
  auto c_frame =
    x.frame(Title("Argus for different values of #it{c}, #it{p} = 10, #it{m}_{0} = 300"));
  m0.setVal(300);
  c.setVal(10);
  p.setVal(10);
  gPad->Clear();
  TLegend legend_c(.5, .6, .92, .92, "Argus shapes:");
  colour = 41;
  for(auto cval : values::c)
  {
    c.setVal(cval);
    const char* name = Form("Argus_c=%d", cval);
    argus.plotOn(c_frame, LineColor(colour), Name(name));
    legend_c.AddEntry(c_frame->findObject(name), Form("#it{c} = %g", cval));
    ++colour;
  }
  c_frame->Draw();
  legend_c.Draw();
  SaveCanvas("Argus_c");
}

int main()
{
  DrawArgusShapes();
  return 0;
}

/// @}